# Process this file with automake to produce a Makefile.in

# Project homepage: http://www.tovid.org
#
#
# Copyright (C) 2005 tovid.org <http://www.tovid.org>
# 
# This program is free software; you can redistribute it and/or 
# modify it under the terms of the GNU General Public License 
# as published by the Free Software Foundation; either 
# version 2 of the License, or (at your option) any later 
# version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Or see:
#
#           http://www.gnu.org/licenses/gpl.txt

# List the source files for each shell script
sh_bin = \
	src/idvid \
	src/makedvd \
	src/makemenu \
	src/makeslides \
	src/makevcd \
	src/makexml \
	src/postproc \
	src/previd \
	src/todisc \
	src/todisc-fade-routine \
	src/tovid \
	src/tovid-batch \
	src/tovid-init \
	src/tovid-interactive \
	src/tovid-test

# List the source files for each python script
py_bin = \
	src/genvid \
	src/pyidvid \
	src/pytovid \
	src/pymakemenu \
	src/pymakexml \
	src/tovidgui \
	src/tovid-stats \
	src/todiscgui

# Specify the scripts to make and install.
bin_SCRIPTS = \
	$(sh_bin) \
	$(py_bin)

# The manpages
man_dir = docs/man
man_src_dir = docs/src/en
man_MANS = \
	$(man_dir)/idvid.1 \
	$(man_dir)/makedvd.1 \
	$(man_dir)/makemenu.1 \
	$(man_dir)/makeslides.1 \
	$(man_dir)/makexml.1 \
	$(man_dir)/postproc.1 \
	$(man_dir)/todisc.1 \
	$(man_dir)/tovid.1
src_MANS = \
	$(man_src_dir)/idvid.t2t \
	$(man_src_dir)/makedvd.t2t \
	$(man_src_dir)/makemenu.t2t \
	$(man_src_dir)/makeslides.t2t \
	$(man_src_dir)/makexml.t2t \
	$(man_src_dir)/postproc.t2t \
	$(man_src_dir)/todisc.t2t \
	$(man_src_dir)/tovid.t2t

# Make the manpages for svn users (tarball users' man pages made in dist-hook)
#   This is a static pattern rule as seen on (TV!)
#   http://www.gnu.org/software/make/manual/make.html#Static-Pattern
$(man_MANS): $(man_dir)/%.1: $(man_src_dir)/%.t2t
	txt2tags -t man -i "$<" -o "$@"

# Distribute the scripts, icons, and manpage source files
# manpages are made and packaged in the dist-hook for tarball users which
# prevents them from having to install txt2tags to make the mans, thus
# they aren't listed here. 
#   NOTE: this is a bit of a hack. When 'make dist' is called, make puts
#   the manpage source in the pre-tarball directory. After everything is 
#   finished, the dist-hook comes into play and fresh man pages are made.
#   We're taking advangtage of this order (make will _always_ do the hook
#   after the action, that's why it's a 'hook'!) to ensure that the derived
#   .1 manpages are newer than the .t2t source files. If the man sources are
#   removed from the distributed tarball, make will try to remake the .1 pages
#   since it always executes rules for targets without prerequisites, 
#   thinking that it's a rule like clean: .
EXTRA_DIST = \
	$(bin_SCRIPTS) \
	$(src_MANS) \
	icons/*

# Shared python libraries: libtovid and the gui
# See lengthy comments in configure.ac
# $(pyexecdir) is the "directory where Python extension modules (shared 
# libraries) should be installed" and is generated by configure.ac's 
# AM_PATH_PYTHON. Typically, this points to 
# $(exec_prefix)/lib/pythonM.m/site-packages
# $(exec_prefix) generally defaults to /usr/local for ./configure 
# and "make install"

# Specifying a module to install: use 'pyexec'
# 'pyexec' works as a prefix of sorts: if you have files that need to be 
# installed into separate directories, use another pyexec variable pair.
# Say you want to install a python module in $(pyexecdir)/FOO , then 
# you'll need to define a pair of variables:
#   (1) pyexecFOO_PYTHON   which takes the python source files
#   (2) pyexecFOOdir       which points to where the module should be installed
#                          (CAPS are not required, but helps readability)
pyexecLIBTOVID_PYTHON = libtovid/*.py
pyexecLIBTOVIDdir = $(pyexecdir)/libtovid

pyexecLIBTOVID_ENCODERS_PYTHON = libtovid/encoders/*.py
pyexecLIBTOVID_ENCODERSdir = $(pyexecdir)/libtovid/encoders

pyexecLIBTOVID_RENDER_PYTHON = libtovid/render/*.py
pyexecLIBTOVID_RENDERdir = $(pyexecdir)/libtovid/render

pyexecGUI_PYTHON = libtovid/gui/*.py
pyexecGUIdir = $(pyexecdir)/libtovid/gui

# src/tovid-init not needed b/c ./configure derives it from src/tovid-init.in
# make fresh man pages for tarball users, esuring that they're newer than the
#   manpage source.
dist-hook:
	rm -rvf $(top_distdir)/src/tovid-init
	mkdir $(distdir)/docs/man
	for manpage_src in $(src_MANS); do \
	  manpage=`echo "$${manpage_src}" | sed 's/t2t/1/g'`; \
	  txt2tags -t man -i $${manpage_src} -o $${manpage}; \
	  mv -v $${manpage} $(distdir)/docs/man; \
	done

# After uninstalling tovid, remove the python module directories
uninstall-hook:
	rmdir $(pyexecLIBTOVID_ENCODERSdir)
	rmdir $(pyexecLIBTOVID_RENDERdir)
	rmdir $(pyexecGUIdir)
	rmdir $(pyexecLIBTOVIDdir)

